package vip.xiaonuo.modular.grouporgrelatechangetemp.service.impl;

import org.springframework.stereotype.Service;
import vip.xiaonuo.facedoor.iservice.megvii.IMemberChangeService;
import vip.xiaonuo.facedoor.modular.memberuser.entity.MemberUser;
import vip.xiaonuo.facedoor.rule.RuleConstant;
import vip.xiaonuo.modular.grouporgrelatechangetemp.entity.GroupOrgRelateChangeTemp;
import vip.xiaonuo.modular.grouporgrelatechangetemp.param.GroupOrgRelateChangeTempParam;
import vip.xiaonuo.modular.grouporgrelatechangetemp.service.GroupOrgRelateChangeTempService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service(RuleConstant.KS + RuleConstant.MEMBER_DEAL_WITH)
public class MemberChangeServiceImpl implements IMemberChangeService {

    @Resource
    private GroupOrgRelateChangeTempService tempService;

    @Override
    public boolean isChanging(MemberUser user) {
        GroupOrgRelateChangeTempParam param = new GroupOrgRelateChangeTempParam();
        param.setStatus(0);
        List<GroupOrgRelateChangeTemp> temps = tempService.list(param);
        temps = temps == null ? temps= new ArrayList<>() : temps;
        param.setStatus(1);
        temps.addAll(tempService.list(param));

        return temps!=null && temps.size()>0;
    }
}
